home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 98 / Skunkware 98.iso / src / fileutil / tar-1.12.tar.gz / tar-1.12.tar / tar-1.12 / scripts / weekly.new < prev   
Text File  |  1990-11-01  |  1KB  |  43 lines

  1. #!/bin/sh
  2. # start doing things
  3. TOBACKUP="albert:/"
  4.  
  5. HOST=`hostname | sed 's/\..*//'`
  6. TAPEFILE=/dev/rfd0a
  7. LOGFILE=tar-out
  8. BLOCKING=20
  9. TAR_PART1="/usr/local/bin/tar clbfVM $BLOCKING"
  10.  
  11. rm -f $LOGFILE
  12.  
  13. mt -f $TAPEFILE rewind
  14.  
  15.     host=`echo $TOBACKUP | sed 's/:.*$//'`;
  16.     fs=`echo $TOBACKUP | sed 's/^.*://'`;
  17.     date=`date`;
  18.     fsname=`echo $TOBACKUP | sed 's/\//:/g'`
  19.  
  20.     TAR_PART2="'Weekly backup of $fs on $host at $date' -C $fs ."
  21.     echo Backing up $TOBACKUP at $date | tee -a $LOGFILE
  22.  
  23.     # Actually back things up.
  24.  
  25.     if [ $HOST != $host ] ; then
  26.         rsh $host $TAR_PART1 $HOST:$TAPEFILE $TAR_PART2
  27.     else
  28.         sh -c "exec $TAR_PART1 $TAPEFILE $TAR_PART2"
  29.     fi
  30.     if [ $? -ne 0 ] ; then
  31.         echo Backup of $TOBACKUP failed. | tee -a $LOGFILE
  32.         echo mts at time of failure | tee -a $LOGFILE
  33.         mts -t $TAPEFILE | tee -a $LOGFILE
  34.         # I'm assuming that the tar will have written an empty
  35.         # file to the tape, otherwise I should do a cat here.
  36.     else
  37.         echo $date > $fsname.lasttar
  38.     fi
  39.     sleep 60;
  40.  
  41. mt -f $TAPEFILE rewind
  42. mt -f $TAPEFILE offl
  43.